package com.yu.admin.modules.app.service;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.yu.admin.modules.app.mapper.AddressAdminMapper;
import com.yu.admin.modules.app.pojo.AddressAdmin;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import javax.annotation.Resource;
import java.util.List;
import java.util.Map;

@Slf4j
@Service
public class AddressAdminService {

    @Resource
    private AddressAdminMapper addressAdminMapper;

    /**
     * 查询所有
     */
    public List<AddressAdmin> getAllAddressAdmins() {
        return addressAdminMapper.selectList(null);
    }

    /**
     * 分页条件查询
     *
     * @param pageNo   页号
     * @param pageSize 页面大小
     * @return Page<AddressAdmin>
     */
    public Page<AddressAdmin> getAddressAdminByPage(int pageNo, int pageSize) {
        Page<AddressAdmin> page = new Page<>(pageNo, pageSize);
        return addressAdminMapper.selectPage(page, null);
    }

    // 增加
    @Transactional
    public int addAddressAdmin(AddressAdmin addressAdmin) {
        return addressAdminMapper.insert(addressAdmin);
    }

    // 批量删除
    @Transactional
    public int deleteAddressAdminBatchIds(List<Integer> addressAdminIdList) {
        return addressAdminMapper.deleteBatchIds(addressAdminIdList);
    }

    // 修改
    @Transactional
    public int updateAddressAdmin(AddressAdmin addressAdmin) {
        return addressAdminMapper.updateById(addressAdmin);
    }
}
